FUNCTION YBC_SWS_GET_APPROVER_NEXT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_APPLEVEL) TYPE  YBC_SWS_APPLEVEL
*"     REFERENCE(IV_UNAME) TYPE  UNAME
*"  TABLES
*"      ET_APPROVER_NEXT STRUCTURE  YBCS_SWS_APPROVER
*"----------------------------------------------------------------------
*  TYPES:
*    BEGIN OF LY_ZAPPROVER_SET,
*      ZAPPROVER TYPE ZAPPROVER, "Approver
*    END OF LY_ZAPPROVER_SET.
*
*  DATA:
*    LV_PERSNUMBER    TYPE AD_PERSNUM, "Person Number
*    LV_APPLEVEL_NUMC TYPE NUMC1,
*    LV_APPLEVEL_NEXT TYPE YBC_SWS_APPLEVEL,
*    LV_CLASS         TYPE XUCLASS. "User Group
*
*  DATA:
*    LS_USER          TYPE YBC_SWS_USER,
*    LS_ZFIORIT0004   TYPE ZFIORIT0004,
*    LS_ZAPPROVER_SET TYPE LY_ZAPPROVER_SET,
*    LS_APPROVER_NEXT TYPE YBCS_SWS_APPROVER,
*    LS_ZFIORIT0006   TYPE ZFIORIT0006.
*
*  DATA:
*    LT_USER          TYPE STANDARD TABLE OF YBC_SWS_USER,
*    LT_ZFIORIT0004   TYPE TABLE OF ZFIORIT0004,
*    LT_ZAPPROVER_SET TYPE TABLE OF LY_ZAPPROVER_SET,
*    LT_ZFIORIT0006   TYPE TABLE OF ZFIORIT0006.
*
*
*
*  CLEAR LV_CLASS.
*  SELECT SINGLE
*        CLASS "User Group
*        INTO LV_CLASS
*        FROM USR02
*        WHERE BNAME = IV_UNAME.
*
*  LV_APPLEVEL_NUMC = IV_APPLEVEL+1(1).
*  LV_APPLEVEL_NUMC =  LV_APPLEVEL_NUMC + 1.
*  LV_APPLEVEL_NEXT = IV_APPLEVEL(1) && LV_APPLEVEL_NUMC.
*
*  SELECT *
*  INTO TABLE LT_ZFIORIT0006
*  FROM ZFIORIT0006
*  WHERE ZWORKFLOW = 'SES'
*    AND ZAPPR_LEVEL = LV_APPLEVEL_NEXT
*    AND ZAPPROVER <> ''.
*
*  IF LT_ZFIORIT0006[] IS NOT INITIAL.
*    SELECT *
*      INTO TABLE LT_ZFIORIT0004
*      FROM ZFIORIT0004 FOR ALL ENTRIES IN LT_ZFIORIT0006
*      WHERE ZAPPR_PROCEDURE = LT_ZFIORIT0006-ZAPPR_PROCEDURE.
*    SORT LT_ZFIORIT0004 BY ZAPPR_PROCEDURE.
*  ENDIF.
*
*  LOOP AT LT_ZFIORIT0006 INTO LS_ZFIORIT0006.
*    CLEAR LS_ZFIORIT0004.
*    READ TABLE LT_ZFIORIT0004 INTO LS_ZFIORIT0004
*      WITH KEY ZAPPR_PROCEDURE = LS_ZFIORIT0006-ZAPPR_PROCEDURE
*      BINARY SEARCH.
*
*    IF LS_ZFIORIT0006-USERID IS NOT INITIAL.
*      IF LS_ZFIORIT0006-USERID = IV_UNAME.
*        IF LS_ZFIORIT0006-ZAPPROVER CS ','.
*          SPLIT LS_ZFIORIT0006-ZAPPROVER AT ',' INTO TABLE LT_ZAPPROVER_SET.
*          LOOP AT LT_ZAPPROVER_SET INTO LS_ZAPPROVER_SET.
*            CLEAR LS_APPROVER_NEXT.
*            LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*            LS_APPROVER_NEXT-USERID = LS_ZAPPROVER_SET-ZAPPROVER.
*            LS_APPROVER_NEXT-SAPID = LS_ZAPPROVER_SET-ZAPPROVER.
*            LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*            LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*
*
*            APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*          ENDLOOP.
*        ELSE.
*          CLEAR LS_APPROVER_NEXT.
*          LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*          LS_APPROVER_NEXT-USERID = LS_ZFIORIT0006-ZAPPROVER.
*          LS_APPROVER_NEXT-SAPID = LS_ZFIORIT0006-ZAPPROVER.
*          LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*        ENDIF.
*      ENDIF.
*
*
*    ELSEIF  LS_ZFIORIT0006-USERGROUP IS NOT INITIAL.
*      IF  LS_ZFIORIT0006-USERGROUP = LV_CLASS.
*        IF LS_ZFIORIT0006-ZAPPROVER CS ','.
*          SPLIT LS_ZFIORIT0006-ZAPPROVER AT ',' INTO TABLE LT_ZAPPROVER_SET.
*          LOOP AT LT_ZAPPROVER_SET INTO LS_ZAPPROVER_SET.
*            CLEAR LS_APPROVER_NEXT.
*            LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*            LS_APPROVER_NEXT-USERID = LS_ZAPPROVER_SET-ZAPPROVER.
*            LS_APPROVER_NEXT-SAPID = LS_ZAPPROVER_SET-ZAPPROVER.
*            LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*            LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*            APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*          ENDLOOP.
*        ELSE.
*          CLEAR LS_APPROVER_NEXT.
*          LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*          LS_APPROVER_NEXT-USERID = LS_ZFIORIT0006-ZAPPROVER.
*          LS_APPROVER_NEXT-SAPID = LS_ZFIORIT0006-ZAPPROVER.
*          LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*        ENDIF.
*      ENDIF.
*
*    ELSE.
*      IF LS_ZFIORIT0006-ZAPPROVER CS ','.
*        SPLIT LS_ZFIORIT0006-ZAPPROVER AT ',' INTO TABLE LT_ZAPPROVER_SET.
*        LOOP AT LT_ZAPPROVER_SET INTO LS_ZAPPROVER_SET.
*          CLEAR LS_APPROVER_NEXT.
*          LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*          LS_APPROVER_NEXT-USERID = LS_ZAPPROVER_SET-ZAPPROVER.
*          LS_APPROVER_NEXT-SAPID = LS_ZAPPROVER_SET-ZAPPROVER.
*          LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*          APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*        ENDLOOP.
*      ELSE.
*        CLEAR LS_APPROVER_NEXT.
*        LS_APPROVER_NEXT-APPLEVEL = LV_APPLEVEL_NEXT.
*        LS_APPROVER_NEXT-USERID = LS_ZFIORIT0006-ZAPPROVER.
*        LS_APPROVER_NEXT-SAPID = LS_ZFIORIT0006-ZAPPROVER.
*        LS_APPROVER_NEXT-APPLEVEL_DESC1 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*        LS_APPROVER_NEXT-APPLEVEL_DESC2 = LV_APPLEVEL_NEXT+1(1) && '.' && LS_ZFIORIT0004-ZAPPR_PRO_NAME.
*        APPEND LS_APPROVER_NEXT TO ET_APPROVER_NEXT.
*      ENDIF.
*    ENDIF.
*  ENDLOOP.
*  SORT ET_APPROVER_NEXT BY SAPID.
*  DELETE ADJACENT DUPLICATES FROM  ET_APPROVER_NEXT COMPARING SAPID.
*
*  IF ET_APPROVER_NEXT[] IS NOT INITIAL.
*    SELECT *
*      INTO TABLE LT_USER
*      FROM YBC_SWS_USER
*      FOR ALL ENTRIES IN ET_APPROVER_NEXT
*     WHERE SAPID = ET_APPROVER_NEXT-SAPID.
*    "OR EMAIL = IT_APPROVER-EMAIL
*    "OR TEL = IT_APPROVER-TEL.
*
** 审批人的名字， 要取ADRP-NAME_TEXT，但是GR 的审批流 中的名字，是取的 YBC_SWS_USER-NAME1
** 所以直接更新  YBC_SWS_USER-NAME1.
*    LOOP AT LT_USER INTO LS_USER.
*      CLEAR LV_PERSNUMBER.
*      SELECT SINGLE
*        PERSNUMBER
*        INTO LV_PERSNUMBER
*        FROM USR21
*        WHERE BNAME = LS_USER-SAPID.
*      IF SY-SUBRC = 0.
*        SELECT SINGLE
*          NAME_TEXT
*          INTO LS_USER-NAME1
*          FROM ADRP
*          WHERE PERSNUMBER = LV_PERSNUMBER.
*        CONCATENATE LS_USER-NAME1 '(' LS_USER-SAPID ')'
*          INTO LS_USER-NAME1.
*      ENDIF.
*      MODIFY LT_USER FROM LS_USER.
*    ENDLOOP.
*    MODIFY YBC_SWS_USER FROM TABLE LT_USER.
*  ENDIF.



ENDFUNCTION.
